<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="./template/layout.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
	<ui:define name="conteudo">
		<div style="margin: 10px 10px 0 10px;">
			<h:form>
				<p:fieldset legend="Emprestimo" >

					<p:panelGrid columns="4" style="width: 100%;" >
						<h:outputText value="Aluno:" />
						<h:outputText value="#{prateleiraBEAN.emprestimo.usuario.nome}" />
						<h:outputText value="Curso:" />
						<h:outputText value="#{prateleiraBEAN.emprestimo.usuario.curso}" />
						<h:outputText value="E-Mail:" />
						<h:outputText value="#{prateleiraBEAN.emprestimo.usuario.email}" />
						<h:outputText value="Data da Reseva:" />
						<h:outputText value="#{prateleiraBEAN.emprestimo.dataReseva}" />
					</p:panelGrid>
					<p:dataTable var="livroEmprestimo"
						value="#{prateleiraBEAN.emprestimo.livros}"
						binding="#{prateleiraBEAN.datatableEmprestimo}" rows="6"
						paginator="true" paginatorPosition="bottom" id="emprestimos">
						<p:column>
							<f:facet name="header">
								<h:outputText value="Nome" />
							</f:facet>
							<h:outputText value="#{livroEmprestimo.nome}" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="Editora" />
							</f:facet>
							<h:outputText value="#{livroEmprestimo.editora.nome}" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="Autor" />
							</f:facet>
							<h:outputText value="#{livroEmprestimo.autores.nome}" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="Remover" />
							</f:facet>
							<p:commandButton icon="ui-icon-trash"
								action="#{prateleiraBEAN.deletarLivro()}" update="emprestimos" />
						</p:column>
					</p:dataTable>
					<p:commandButton icon="ui-icon-check" value="Fazer Emprestimo"
						action="#{prateleiraBEAN.fazerEmprestimo()}" update="emprestimos"/>
					<p:commandButton icon="ui-icon-circle-close" value="Limpar"
						action="#{prateleiraBEAN.limparEmprestimo()}" update="emprestimos"/>
				</p:fieldset>
				<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>  
				<p:dialog widgetVar="statusDialog" header="Status"   
				        draggable="false" closable="false">  
				    <p:graphicImage value="/images/ajaxloadingbar.gif" />  
				</p:dialog> 
			</h:form>
		</div>
	</ui:define>
</ui:composition>